<?php
class transactiondao extends CI_Model{
	function __construct()
	{
		// Call the Model constructor
		parent::__construct();
	}
	function insert($transaction_date, $user_id, $neighborhood_id,
			$market_id){
		$data = array(
				'transaction_date'	=> $transaction_date,
				'user_id'	=> $user_id,
				'neighborhood_id'	=> $neighborhood_id,
				'market_id'	=> $market_id
		);
	
		$str = $this->db->insert_string('transaction', $data);
		$res = $this->db->query($str);
		if (!$res) {
			return 0;
		} else {
			$return_id = $this->db->insert_id();
			array_push($data,
			array('transaction_id' => $return_id));
			return $data;
		}
	
	}
	public function getbyid($id){
		$this->db->select('*');
		$this->db->from('transaction');
		$this->db->where('transaction_id',$id);
		$query = $this->db->get();
		$transaction = $query->row();
		return $transaction;
	}
	
	public function get_all(){
		$this->db->select('*');
		$this->db->from('transaction');
		$query = $this->db->get();
		$transactions = $query->result();
		return $transactions;
	}
}
?>